#ifndef _PBCGSOLVER_H_
#define _PBCGSOLVER_H_

#include <cstdio>
#include <cstddef>
#include <cstdlib>
#include <cmath>
#define EPS 1.0e-14

class PBCG  
{
public:
	PBCG();
	virtual ~PBCG();
  void setSize(int size);
  void setSa(int index, double value) { sa[index] = value; };
  void setIja(int index, unsigned long value) { ija[index] = value; };
	void linbcg(unsigned long n, double b[], double x[], int itol, double tol, int itmax, int *iter, double *err);

private:
	void dsprstx(double sa[], unsigned long ija[], double x[], double b[], unsigned long n);
	void dsprsax(double sa[], unsigned long ija[], double x[], double b[], unsigned long n);
	double snrm(unsigned long n, double sx[], int itol);
	void atimes(unsigned long n, double x[], double r[], int itrnsp);
	void asolve(unsigned long n, double b[], double x[], int itrnsp);

private:
	unsigned long *ija;
  double *sa;
};

#endif 
